#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
void input(int* a)
{
	int i = 0;
	for (i = 0; i < 10; i++)
		scanf("%d", &a[i]);
}
void solve(int* a)
{
	int* i = a;
	int* j = a;
	int* x = 0;
	int t = 0;

	for (x = a + 1; x < a + 10; x++)
		if (*i > *x)
			i = x;
	t = a[0];
	a[0] = *i;
	*i = t;
	for (x = a + 1; x < a + 10; x++)
		if (*j < *x)
			j = x;
	t = a[9];
	a[9] = *j;
	*j = t;
}
void output(int* a)
{
	int i = 0;
	for (i = 0; i < 10; i++)
	{
		printf("%d ", a[i]);
	}

}
int main()
{
	int a[] = { 0 };
	input(a);
	solve(a);
	output(a);
	return 0;
}